package pack0812;

public class Work14 {
    //14：编写程序，将一个二维数组的行列互换。（二维数组）
    public static void main(String[] args) {
        int[][] a = {{1,4,7,2},{3,6,9,4,5,6},{5,6,2,3,4}};
        int sum = 0;
       for(int i=0 ;i<a.length; i++){
            if(a[i].length>sum){
                sum=a[i].length;
            }
       }
       int[][] b = new int[sum][a.length];
       for(int i=0; i<a.length;i++){
           for(int j = 0; j<a[i].length;j++){
               b[j][i]=a[i][j];
           }
       }
       for(int i = 0;i<b.length;i++){
           for(int j = 0; j<b[i].length;j++){
               System.out.print(b[i][j]+"\t");
           }
           System.out.println();
       }
    }
}
